home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-01 / dmake38c.zip / EXPLODE.C < prev    next >
C/C++ Source or Header  |  1992-01-23  |  4KB  |  148 lines

  1. /* RCS      -- $Header: /u2/dvadura/src/generic/dmake/src/unix/explode.c,v 1.1 1992/01/24 03:28:28 dvadura Exp $
  2. -- SYNOPSIS -- Routines to explode dag if .SETDIR targets present.
  3. -- 
  4. -- DESCRIPTION
  5. --    These routines are called by parallel dmake implementations to
  6. --    explode the dmake DAG at .SETDIR targets so that parallel makes
  7. --    can traverse common portions of the DAG in parallel.
  8. -- 
  9. -- AUTHOR
  10. --      Dennis Vadura, dvadura@watdragon.uwaterloo.ca
  11. --      CS DEPT, University of Waterloo, Waterloo, Ont., Canada
  12. --
  13. -- COPYRIGHT
  14. --      Copyright (c) 1990 by Dennis Vadura.  All rights reserved.
  15. -- 
  16. --      This program is free software; you can redistribute it and/or
  17. --      modify it under the terms of the GNU General Public License
  18. --      (version 1), as published by the Free Software Foundation, and
  19. --      found in the file 'LICENSE' included with this distribution.
  20. -- 
  21. --      This program is distributed in the hope that it will be useful,
  22. --      but WITHOUT ANY WARRANTY; without even the implied warrant of
  23. --      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  24. --      GNU General Public License for more details.
  25. -- 
  26. --      You should have received a copy of the GNU General Public License
  27. --      along with this program;  if not, write to the Free Software
  28. --      Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  29. --
  30. -- LOG
  31. --     $Log: explode.c,v $
  32.  * Revision 1.1  1992/01/24  03:28:28  dvadura
  33.  * dmake Version 3.8, Initial revision
  34.  *
  35. */
  36.  
  37. #include "extern.h"
  38. #include "alloc.h"
  39. #include "db.h"
  40.  
  41. CELLPTR
  42. Explode_cell( cp, dir )
  43. CELLPTR cp;
  44. CELLPTR dir;
  45. {
  46.    int explode = FALSE;
  47.    CELLPTR root;
  48.    CELLPTR tcp;
  49.    CELLPTR ocp;
  50.    HOWPTR  fhow = NIL(HOW);
  51.  
  52.  
  53.    if( cp == NIL(CELL) ) return(cp);
  54.  
  55.    ocp = cp;
  56.    if( (root = cp->ce_name->CP_ROOT) != dir ) {
  57.       if( cp->ce_name->CP_ROOT != NIL(CELL) ) {
  58.      HASHPTR name;
  59.  
  60.      tcp  = Def_cell(cp->CE_NAME, dir);
  61.      name = tcp->ce_name;
  62.      *tcp = *cp;
  63.      tcp->ce_name = name;
  64.  
  65.      cp = tcp;
  66.      explode = TRUE;
  67.       }
  68.    }
  69.    else if( root && root == dir )
  70.       return( cp );
  71.  
  72.    /* The code here is required, as it takes care of the .UPDATEALL common
  73.     * targets. */
  74.    tcp = cp;
  75.    do {
  76.       tcp->ce_name->CP_ROOT = dir;
  77.  
  78.       if( tcp->CE_HOW != fhow ) {
  79.      tcp->CE_HOW = Explode_how( tcp->CE_HOW, cp->ce_dir?cp:dir, explode );
  80.      if( tcp == cp ) fhow = tcp->CE_HOW;
  81.       }
  82.  
  83.       if( explode && tcp->ce_all )
  84.          if( tcp->ce_all != ocp ) {
  85.         CELLPTR ttcp = Def_cell( tcp->ce_all->CE_NAME, dir );
  86.         HASHPTR name = ttcp->ce_name;
  87.  
  88.         *ttcp = *tcp->ce_all;
  89.         ttcp->ce_name = name;
  90.         tcp->ce_all   = ttcp;
  91.         ttcp->CE_HOW  = fhow;
  92.      }
  93.      else
  94.         tcp->ce_all = cp;
  95.  
  96.       tcp = tcp->ce_all;
  97.    }
  98.    while( tcp != NIL(CELL) && tcp != cp );
  99.  
  100.    return( cp );
  101. }
  102.  
  103.  
  104. HOWPTR
  105. Explode_how( how, dir, copy )
  106. HOWPTR  how;
  107. CELLPTR dir;
  108. int     copy;
  109. {
  110.    if( how == NIL(HOW) ) return( how );
  111.  
  112.    if( copy ) {
  113.       HOWPTR thow;
  114.  
  115.       TALLOC( thow, 1, HOW );
  116.       *thow = *how;
  117.       how = thow;
  118.    }
  119.  
  120.    how->hw_next = Explode_how( how->hw_next, dir, copy );
  121.    how->hw_prq  = Explode_prq( how->hw_prq, dir, copy );
  122.  
  123.    return( how );
  124. }
  125.  
  126.  
  127. LINKPTR
  128. Explode_prq( prq, dir, copy )
  129. LINKPTR prq;
  130. CELLPTR dir;
  131. int     copy;
  132. {
  133.    if( prq == NIL(LINK) ) return(prq);
  134.  
  135.    if( copy ) {
  136.       LINKPTR tprq;
  137.  
  138.       TALLOC( tprq, 1, LINK );
  139.       *tprq = *prq;
  140.       prq = tprq;
  141.    }
  142.  
  143.    prq->cl_next = Explode_prq( prq->cl_next, dir, copy );
  144.    prq->cl_prq  = Explode_cell( prq->cl_prq, dir );
  145.  
  146.    return( prq );
  147. }
  148.